package com.grm.sys.controller;

import com.grm.common.entity.Result;
import com.grm.sys.model.SysUser;
import com.grm.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sys/user")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    @PostMapping("/list")
    public Result list(Long pageNum, Integer pageSize, @RequestBody SysUser queryParam) {
        List<SysUser> dataList = sysUserService.querySelective(pageNum, pageSize, queryParam);
        Long total = sysUserService.queryTotal(queryParam);
        return Result.success(dataList, total);
    }

    @PostMapping("/add")
    public Result add(@RequestBody SysUser sysUser) {
        sysUserService.add(sysUser);
        return Result.success();
    }

    @GetMapping("/all")
    public Result queryAll() {
        List<SysUser> dataList = sysUserService.queryAll();
        return Result.success(dataList);
    }
}
